﻿
Namespace LightSwitchApplication

    Public Class DateTracking

        Private Sub TotalDays_Compute(ByRef result As System.Nullable(Of Integer))
            ' Set result to the desired field value
            Dim diff As TimeSpan
            If Not IsNothing(Me.StartDate) Then
                If Not IsNothing(Me.EndDate) Then
                    diff = Me.EndDate - Me.StartDate
                    result = diff.Days
                Else
                    diff = Today - Me.StartDate
                    result = diff.Days
                End If
            End If
        End Sub

        Private Sub BoardingCost_Compute(ByRef result As System.Nullable(Of Decimal))
            ' Set result to the desired field value
            If Not IsNothing(Me.TotalDays) Then
                If Not IsNothing(Me.Animal.DailyBoardingFee) Then
                    result = Me.TotalDays * Me.Animal.DailyBoardingFee
                End If
            End If
        End Sub
    End Class

End Namespace
